package com.smartstate.dataManagement.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smartstate.dataManagement.dto.PageDTO;
import com.smartstate.dataManagement.entity.AssetSituation;
import com.smartstate.dataManagement.service.AssetService;
import com.smartstate.dataManagement.vo.ResultVO;
import io.swagger.annotations.ApiOperation;
import org.quartz.SchedulerException;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;

@RestController
@RequestMapping("/Asset")
@ApiOperation("园区资产控制层")
public class AssetController implements Serializable {

    @Resource
    private AssetService assetService;

    @PostMapping("/save")
    @ApiOperation(value = "新增资产")
    public ResultVO<Boolean> save(@RequestBody AssetSituation assetSituation ) {
        return ResultVO.ok(assetService.save(assetSituation));
    }

    @DeleteMapping("/removeById")
    @ApiOperation(value = "根据ID删除")
    public ResultVO<Boolean> removeById(@RequestParam int id) throws SchedulerException {
        return ResultVO.ok(assetService.removeAssetById(id));
    }

    @PostMapping("/updateById")
    @ApiOperation(value = "修改资产")
    public ResultVO<Boolean> updateById(@RequestBody AssetSituation assetSituation ) {
        return ResultVO.ok(assetService.updateById(assetSituation));
    }

    @PostMapping("/pageAsset")
    @ApiOperation(value = "单表分页查询")
    public Page<AssetSituation> pageEquipment(@RequestBody PageDTO<AssetSituation> pageDTO) {
        return assetService.queryAllPageByDTO(pageDTO);
    }
}
